package guoanmaker.operator.business.controller;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import guoanmaker.operator.business.service.StoreManageService;
import guoanmaker.operator.helper.common.AjaxJson;
import guoanmaker.operator.helper.common.abstractobj.ApiController;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping(ApiController.OPERATOR_USER)
public class StoreManageController {
	
	

	
	@Resource
	private StoreManageService storeManageService;
	
	/**
	 * 
	 * @param page                        默认为0
	 * @param size                        每页10条
	 * @param companyName                 公司名称
	 * @param serverClass                 服务种类
	 * @param serverZone                  服务地区
	 * @return
	 */
	@ApiOperation(value = "动态查询店铺列表",notes="按照公司名称，服务种类，服务地区，查询店铺列表")
	@RequestMapping(value ="selectByAccountforStore",method = RequestMethod.POST)
	public AjaxJson selectByAccountforStore( Integer page,
            Integer size, String serverClass,String companyName,String serverZone){
		AjaxJson ajaxJson=new AjaxJson();
		try {
			ajaxJson.setSuccess(true).setStatus(200).setMsg("操作成功").setData(storeManageService.selectByAccountforStore(page,size
					,serverClass,companyName,serverZone));
		} catch (Exception e) {
			ajaxJson.setSuccess(false).setStatus(500).setMsg("操作失败").setData("error");
		}
		return ajaxJson;
	}
	
	//服务地区下拉接口
	@ApiOperation(value = "服务地区下拉接口",notes="服务地区下拉接口列表")
	@RequestMapping(value ="selectByServiceZone",method = RequestMethod.POST)
	public AjaxJson selectByServiceZone(){
		AjaxJson ajaxJson=new AjaxJson();
		try {
			ajaxJson.setSuccess(true).setStatus(200).setMsg("操作成功").setData(storeManageService.selectByServiceZone());
		} catch (Exception e) {
			ajaxJson.setSuccess(false).setStatus(500).setMsg("操作失败").setData("error");
		}
		return ajaxJson;
	}
	//更新服务商来源
	@ApiOperation(value = "更新服务商来源",notes="更新服务商来源")
	@RequestMapping(value ="updateSouceServiceProvide",method = RequestMethod.POST)
	public AjaxJson updateSouceServiceProvide(String id,String sourceName){
		AjaxJson ajaxJson=new AjaxJson();
		try {
			ajaxJson.setSuccess(true).setStatus(200).setMsg("操作成功").setData(storeManageService.updateSouceServiceProvide(id,sourceName));
		} catch (Exception e) {
			ajaxJson.setSuccess(false).setStatus(500).setMsg("操作失败").setData("error");
		}
		return ajaxJson;
	}
	
	//店铺详情
	@ApiOperation(value = "店铺详情",notes="店铺详情")
	@RequestMapping(value ="selectByShopinfo",method = RequestMethod.POST)
	public AjaxJson selectByShopinfo(String id){
		AjaxJson ajaxJson=new AjaxJson();
		try {
			ajaxJson.setSuccess(true).setStatus(200).setMsg("操作成功").setData(storeManageService.selectByShopinfo(id));
		} catch (Exception e) {
			ajaxJson.setSuccess(false).setStatus(500).setMsg("操作失败").setData("error");
		}
		return ajaxJson;
	}
	@ApiOperation(value = "店铺详情",notes="店铺详情")
	@RequestMapping(value ="selectByShopinfo1",method = RequestMethod.POST)
	public AjaxJson selectByShopinfo1(String id){
		AjaxJson ajaxJson=new AjaxJson();
		try {
			ajaxJson.setSuccess(true).setStatus(200).setMsg("操作成功").setData(storeManageService.selectByShopinfo1(id));
		} catch (Exception e) {
			ajaxJson.setSuccess(false).setStatus(500).setMsg("操作失败").setData("error");
		}
		return ajaxJson;
	}
	
	//店铺下所有商品
	@ApiOperation(value = "店铺下所有商品列表",notes="店铺下所有商品列表")
	@RequestMapping(value ="selectByShopforCommditys",method = RequestMethod.POST)
	public AjaxJson selectByShopforCommditys(String id,String busid, Integer page,
            Integer size){
		AjaxJson ajaxJson=new AjaxJson();
		try {
			ajaxJson.setSuccess(true).setStatus(200).setMsg("操作成功").setData(storeManageService.selectByShopforCommditys(id,busid,page,size));
		} catch (Exception e) {
			ajaxJson.setSuccess(false).setStatus(500).setMsg("操作失败").setData("error");
		}
		return ajaxJson;
	}
	
	/**********************店铺资料变更管理************************************/
	
	/**
	 * 
	 * @param page
	 * @param size
	 * @param status  0----> 待审核    2----》已拒绝   1-----》已通过
	 * @return
	 */
	@ApiOperation(value = "店铺资料变更审核列表")
	@RequestMapping(value ="pendingStoreList",method = RequestMethod.POST)
	public AjaxJson pendingStoreList(@RequestParam(value = "page", defaultValue = "0") Integer page,
            @RequestParam(value = "size", defaultValue = "10") Integer size,Integer status){
		AjaxJson ajaxJson=new AjaxJson();
		try {
			ajaxJson.setSuccess(true).setStatus(200).setMsg("操作成功").setData(storeManageService.pendingStoreList(page,size,status));
		} catch (Exception e) {
			ajaxJson.setSuccess(false).setStatus(500).setMsg("操作失败").setData("error");
		}
		return ajaxJson;
	}
	
	/**
	 * 审核资料变更通过
	 * @param busid
	 * @param storeid
	 * @return
	 */
	@ApiOperation(value = "审核资料变更通过")
	@RequestMapping(value ="auditStoreinfo",method = RequestMethod.POST)
	public AjaxJson auditStoreinfo(String busid,String storeid,String userid){
		AjaxJson ajaxJson=new AjaxJson();
		try {
			ajaxJson.setSuccess(true).setStatus(200).setMsg("操作成功").setData(storeManageService.auditStoreinfo(busid,storeid,userid));
		} catch (Exception e) {
			ajaxJson.setSuccess(false).setStatus(500).setMsg("操作失败").setData("error");
		}
		return ajaxJson;
	}
	
	/**
	 * 审核资料变更拒绝
	 * @param busid
	 * @param storeid
	 * @return
	 */
	@ApiOperation(value = "审核资料变更拒绝")
	@RequestMapping(value ="refuseStoreinfo",method = RequestMethod.POST)
	public AjaxJson refuseStoreinfo(String storeid,String userid,String reasonName,String content){
		AjaxJson ajaxJson=new AjaxJson();
		try {
			ajaxJson.setSuccess(true).setStatus(200).setMsg("操作成功").setData(storeManageService.refuseStoreinfo(storeid,userid,reasonName,content));
		} catch (Exception e) {
			ajaxJson.setSuccess(false).setStatus(500).setMsg("操作失败").setData("error");
		}
		return ajaxJson;
	}
	
	/**
	 * 店铺资料变更详情   
	 * 
	 * 
	 */
	@ApiOperation(value = "店铺资料变更详情 ")
	@RequestMapping(value ="storeinfos",method = RequestMethod.POST)
	public AjaxJson storeinfos(String busid,String storeid,String sid){
		AjaxJson ajaxJson=new AjaxJson();
		try {
			ajaxJson.setSuccess(true).setStatus(200).setMsg("操作成功").setData(storeManageService.storeinfos(busid,storeid,sid));
		} catch (Exception e) {
			ajaxJson.setSuccess(false).setStatus(500).setMsg("操作失败").setData("error");
		}
		return ajaxJson;
	}
	
}
